﻿using Models.Common;
using MQTTnet.Client;
using MQTTnet.Protocol;
using NewLife.Data;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using UtilsBase;
using UtilsCache;
using UtilsMQ;
using UtilsMQ.Model;

namespace ServiceWeb.APIRequest
{
    public class ServiceWebMqttClient : MqttClientService
    {
        public ServiceWebMqttClient()
        {
            ConstantMqtt.ip = UtilAppsettingCache.getSetting("mqtt:hostName");
            ConstantMqtt.port = int.Parse(UtilAppsettingCache.getSetting("mqtt:port"));
            ConstantMqtt.username = UtilAppsettingCache.getSetting("mqtt:userName");
            ConstantMqtt.password = UtilAppsettingCache.getSetting("mqtt:password");
        }


      

        public bool sendMsg(string data)
        {
            return new MqttClientService().Publish(ConstantMqtt.gateway_server_topic, data);
        }
    }
}
